{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\anaconda3\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3146: DtypeWarning: Columns (4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19) have mixed types.Specify dtype option on import or set low_memory=False.\n",
      "  has_raised = await self.run_ast_nodes(code_ast.body, cell_name,\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "按手机价格统计评分:\n",
      "                                                     max   min  mean  median\n",
      "价格                                                                          \n",
      " the USB Earbuds cable is 36 inches and the USB...  30.0  29.0  29.6    30.0\n",
      "\n",
      "按手机品牌统计评分:\n",
      "                                                     max   min  mean  median\n",
      "手机品牌                                                                        \n",
      " and serve as the FM Radio antenna. Both cable ...  30.0  29.0  29.6    30.0\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "# 读取数据文件，指定编码为'ISO-8859-1'\n",
    "data = pd.read_csv('C:\\\\Users\\\\Administrator\\\\Desktop\\\\Mobile.csv', header=None, names=['手机品牌', '价格', '评分'], encoding='ISO-8859-1')\n",
    "\n",
    "# 按手机价格统计评分最大值、最小值、算术平均值和中位数\n",
    "price_stats = data.groupby('价格')['评分'].agg(['max', 'min', 'mean', 'median'])\n",
    "print(\"按手机价格统计评分:\")\n",
    "print(price_stats)\n",
    "\n",
    "# 按手机品牌统计评分最大值、最小值、算术平均值和中位数\n",
    "brand_stats = data.groupby('手机品牌')['评分'].agg(['max', 'min', 'mean', 'median'])\n",
    "print(\"\\n按手机品牌统计评分:\")\n",
    "print(brand_stats)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
